package me.boot.lock;

import com.baomidou.lock.annotation.Lock4j;
import com.baomidou.lock.executor.RedissonLockExecutor;
import lombok.Data;
import org.springframework.stereotype.Service;

/**
 * 入门使用
 */
@Service
public class QuickStartService {

    //默认获取锁超时3秒，30秒锁过期
    @Lock4j
    public void f1() {
        //do something
    }

    //完全配置，支持spel
    @Lock4j(keys = {"#user.id", "#user.name"}, expire = 60000, acquireTimeout = 1000)
    public void f2(User user) {
        //do something
    }

    //可在方法级指定使用某种执行器，若自己实现的需要提前注入到Spring。
    @Lock4j(executor = RedissonLockExecutor.class)
    public void f3() {
        //do something
    }


    @Data
    public static class User {
        private Long id;
        private String name;
    }
}